CREATE TABLE [dbo].[QuotesGallery](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](256) NOT NULL,
	[CreatedBy] [uniqueidentifier] NULL,
	[CreatedDate] [datetime] NOT NULL,
	[ModifiedBy] [uniqueidentifier] NULL,
	[ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_QuoteGallery.QuotesGallery] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[QuotesGallery]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery_Users] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery] CHECK CONSTRAINT [FK_QuotesGallery_Users]
GO
ALTER TABLE [dbo].[QuotesGallery]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery_Users1] FOREIGN KEY([ModifiedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery] CHECK CONSTRAINT [FK_QuotesGallery_Users1]
GO

CREATE TABLE [dbo].[QuotesGallery.Authors](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](256) NOT NULL,
	[Slug] [nvarchar](256) NOT NULL,
	[CreatedBy] [uniqueidentifier] NULL,
	[CreatedDate] [datetime] NOT NULL,
	[ModifiedBy] [uniqueidentifier] NULL,
	[ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_QuotesGallery.Authors] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[QuotesGallery.Authors]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Authors_Users] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Authors] CHECK CONSTRAINT [FK_QuotesGallery.Authors_Users]
GO
ALTER TABLE [dbo].[QuotesGallery.Authors]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Authors_Users1] FOREIGN KEY([ModifiedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Authors] CHECK CONSTRAINT [FK_QuotesGallery.Authors_Users1]
GO


CREATE TABLE [dbo].[QuotesGallery.Sources](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](256) NOT NULL,
	[Slug] [nvarchar](256) NOT NULL,
	[CreatedBy] [uniqueidentifier] NULL,
	[CreatedDate] [datetime] NOT NULL,
	[ModifiedBy] [uniqueidentifier] NULL,
	[ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_QuoteGallery.Sources] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[QuotesGallery.Sources]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Sources_Users1] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Sources] CHECK CONSTRAINT [FK_QuotesGallery.Sources_Users1]
GO
ALTER TABLE [dbo].[QuotesGallery.Sources]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Sources_Users2] FOREIGN KEY([ModifiedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Sources] CHECK CONSTRAINT [FK_QuotesGallery.Sources_Users2]
GO

CREATE TABLE [dbo].[QuotesGallery.Categories](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](256) NOT NULL,
	[Slug] [nvarchar](256) NOT NULL,
	[ParentId] [uniqueidentifier] NULL,
	[GalleryId] [uniqueidentifier] NOT NULL,
	[CreatedBy] [uniqueidentifier] NULL,
	[CreatedDate] [datetime] NOT NULL,
	[ModifiedBy] [uniqueidentifier] NULL,
	[ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_QuotesGallery.Categories] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[QuotesGallery.Categories]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Categories_QuotesGallery] FOREIGN KEY([GalleryId])
REFERENCES [dbo].[QuotesGallery] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Categories] CHECK CONSTRAINT [FK_QuotesGallery.Categories_QuotesGallery]
GO
ALTER TABLE [dbo].[QuotesGallery.Categories]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Categories_Users] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Categories] CHECK CONSTRAINT [FK_QuotesGallery.Categories_Users]
GO
ALTER TABLE [dbo].[QuotesGallery.Categories]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Categories_Users1] FOREIGN KEY([ModifiedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Categories] CHECK CONSTRAINT [FK_QuotesGallery.Categories_Users1]


CREATE TABLE [dbo].[QuotesGallery.QuoteCategories](
	[Id] [uniqueidentifier] NOT NULL,
	[CategoryId] [uniqueidentifier] NOT NULL,
	[QuoteId] [uniqueidentifier] NOT NULL,
	[CreatedBy] [uniqueidentifier] NULL,
	[CreatedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_QuotesGallery.QuoteCategories] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[QuotesGallery.QuoteCategories]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.QuoteCategories_Users] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.QuoteCategories] CHECK CONSTRAINT [FK_QuotesGallery.QuoteCategories_Users]
GO

CREATE TABLE [dbo].[QuotesGallery.Quotes](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](max) COLLATE Ukrainian_CI_AS NOT NULL,
	[AuthorId] [uniqueidentifier] NULL,
	[SourceId] [uniqueidentifier] NULL,
	[CreatedBy] [uniqueidentifier] NULL,
	[CreatedDate] [datetime] NOT NULL,
	[ModifiedBy] [uniqueidentifier] NULL,
	[ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_QuoteGallery.Quote] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[QuotesGallery.Quotes]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Quotes_QuotesGallery.Authors] FOREIGN KEY([AuthorId])
REFERENCES [dbo].[QuotesGallery.Authors] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Quotes] CHECK CONSTRAINT [FK_QuotesGallery.Quotes_QuotesGallery.Authors]
GO
ALTER TABLE [dbo].[QuotesGallery.Quotes]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Quotes_QuotesGallery.Sources] FOREIGN KEY([SourceId])
REFERENCES [dbo].[QuotesGallery.Sources] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Quotes] CHECK CONSTRAINT [FK_QuotesGallery.Quotes_QuotesGallery.Sources]
GO
ALTER TABLE [dbo].[QuotesGallery.Quotes]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Quotes_Users] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Quotes] CHECK CONSTRAINT [FK_QuotesGallery.Quotes_Users]
GO
ALTER TABLE [dbo].[QuotesGallery.Quotes]  WITH CHECK ADD  CONSTRAINT [FK_QuotesGallery.Quotes_Users1] FOREIGN KEY([ModifiedBy])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[QuotesGallery.Quotes] CHECK CONSTRAINT [FK_QuotesGallery.Quotes_Users1]
GO